<?php
/**
 * vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
 */

// Load the Xdms_Table object via factory
$table = Solar::factory('Xdms_Table');

// Set the <table> tag attributes
$table->setAttrib(array(
    'cellspacing' => 1,
    'cellpadding' => 1,
    'style'       => 'margin: 5px auto 5px 5px;',
));

// Set the table caption
$table->setCaption(
    'Address Book',
    array('style'   => 'text-decoration: underline;'
));

// Add a row into table head
$table->setHeadRow(
    // column specification array
    array(
        // column 1 only has content
        "Name",
        // column 2 has content and attribs
        array(
            'content' => 'Email',
            // override the default cell style
            'attribs' => array('style' => 'background: #ffcccc;'),
            // do not use <th>, meaning <td> is used instead
            'use_th' => false,
        ),
        // column 3 has only content
        "Address",
    ),
    // default attribs for all <th> and <td>
    array('style' => 'background: #ffffff;',)
);

// Columns may be added without any attributes too.
$table->setBodyRow(array(
    'Alfred E. Oldman',
    'oldman_randomshit@gmail.com',
    '13A, North Tyndall Ave, Utopia, CA 90028.',
));

echo $this->table($table);
